#include "EKThreadEvent.h"

FEKEvent::FEKEvent()
	: m_bWaiting(false)
	, m_pThreadEvent(FPlatformProcess::GetSynchEventFromPool())
{

}

FEKEvent::~FEKEvent()
{
	FPlatformProcess::ReturnSynchEventToPool(m_pThreadEvent);
	m_pThreadEvent = nullptr;
}

void FEKEvent::Wait()
{
	m_bWaiting = true;
	m_pThreadEvent->Wait();
}

void FEKEvent::Wait(uint32 WaitTime, const bool bIgnoreThreadIdleStats /*= false*/)
{
	m_bWaiting = true;
	m_pThreadEvent->Wait(WaitTime, bIgnoreThreadIdleStats);
}

void FEKEvent::Wait(const FTimespan& WaitTime, const bool bIgnoreThreadIdleStats /*= false*/)
{
	m_bWaiting = true;
	m_pThreadEvent->Wait(WaitTime, bIgnoreThreadIdleStats);
}

void FEKEvent::Trigger()
{
	m_pThreadEvent->Trigger();
	m_bWaiting = false;
}